﻿using System.Collections.Generic;
using Index.Interfaces;

namespace Index.TokenMap
{
    public class Token : IToken
    {
        public const int IdLength = 10;
        public const string IdFormat = "0000000000";

        public string Text { get; set; }
        public uint Id { get; set; }
    
        public Token()
        {
            
        }

        public Token(uint id, string text)
        {
            this.Id = id;
            this.Text = text.Trim().ToLower();
        }

        public override string ToString()
        {
            return (this.Text + ": " + this.Id.ToString("0000000000"));
        }
    }

    public class TokenTextComparer : IComparer<IToken>
    {
        #region IComparer<Token> Members

        public int Compare(IToken x, IToken y)
        {
            if(x == null || y == null)
            {
                return int.MinValue;
            }

            return x.Text.CompareTo(y.Text);
        }

        #endregion
    }
}